﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.Caching;

namespace _18miljard.Menu
{
	public class MenuCache
	{
		internal static MenuCollection Menus
		{
			get
			{
				string cacheName = "data_menus";

				MenuCollection menus = MenuCache.Cache[cacheName] as MenuCollection;

				if (menus == null)
				{
					menus = new MenuCollection();

					CacheDependency dependency = new CacheDependency(HttpContext.Current.Server.MapPath("/App_Data/TopMenu.xml"));

					MenuCache.Cache.Insert(cacheName, menus, dependency);
				}

				return menus;
			}
		}

		private static Cache Cache
		{
			get { return HttpContext.Current.Cache; }
		}
	}
}
